package com.dingwen.treasure.kettle.controller;

import com.dingwen.treasure.kettle.base.controller.BaseViewController;
import com.dingwen.treasure.kettle.base.vo.Result;
import groovy.util.logging.Slf4j;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.time.LocalDateTime;
import java.util.Map;

/**
 * 　TestController
 * 　@author dingwen
 * 　@date 2022/8/25
 */
@Api(tags = "TestController")
@RestController
@Slf4j
@RequestMapping("test")
public class TestController implements BaseViewController {


    @ApiOperation(value = "测试请求参数")
    @ApiImplicitParam(name = "requestParams", value = "requestParams")
    @PostMapping("params")
    public Result<Map<Object, Object>> testRequestParams(@RequestBody Map<Object, Object> requestParams) {
        return success(requestParams);
    }

    @ApiOperation(value = "测试请求头参数")
    @PostMapping("head")
    public Result<String> testRequestParams(HttpServletRequest request) {
        String header = request.getHeader("testHead");
        return success(header,true);
    }

    public static void main(String[] args) {
        String s = LocalDateTime.now().toString();
        System.out.println(s);
    }
}
